<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>


<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="<%=basePath%>"/>
    <title>修改用户资料</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=7" />
	<meta http-equiv="pragma" content="no-cache"/>
	<meta http-equiv="cache-control" content="no-cache"/>
	<meta http-equiv="expires" content="0"/>
	
    <link id="editCss" rel="stylesheet" type="text/css" href="<%=path %>/css/style.css" />
    <link id="editCss" rel="stylesheet" type="text/css" href="<%=path%>/css/right.css" />
    	<style type="text/css">
		#updateUserForm label.error{font-size:12px;color:red;}
		</style>
   	<script src="<%=path%>/js/jquery.js" type="text/javascript"></script>
		<script src="<%=path%>/js/jquery.validate.js" type="text/javascript"></script>
		
    <script type="text/javascript">
     
        function updateEmailNotifications(){
        	var emailNotifications_c = document.updateUserForm.emailNotifications_c;//是否接收邮件通知
        	if(emailNotifications_c.checked){
        		document.updateUserForm.emailN.value = 1;
        	}else{
        		document.updateUserForm.emailN.value = 0;
        	}
        }
    </script>
    <!-- validate begin  -->
		<script type="text/javascript">
	   function sel(){
           if($('#userRole').selectedIndex =='0'){
					alert("userRole");
					return  false;
         		  }
           }
       
    $( function(){
               $("#updateUserForm").validate({
             rules:{ userName: {
                                        required:true,
                                        minlength:2,
                                        maxlength:30
                          }, emailAddress:{
                                email:true,
							    required:true
                          }
                    }, messages:{
                                    userName:{ required:"请填写真实姓名!",minlength:"太短",maxlength:"太长"},
                                    emailAddress:{ required:"请填写邮箱!",email:"邮箱格式错误!" }
                           },submitHandler: function(form) {
                        	  if($("#userRole")[0].options[$("#userRole")[0].selectedIndex].value =='0'){
             					alert("请选择用户角色");
             					return  false;
                      		  }else{
                      			doVali();
                      			if(isOkVali()==true){
                      				form.submit();
                          			}
								  }
                                }
                    }); });	
	</script>
		<!-- validate end  -->
    
    
  </head>
  
<body class="bg">

<div id="nav" class="crumbs">
	当前位置：<a href="<%=path %>/servlet/ShowListServlet?key=cusList" class="title">客户管理</a> >修改用户
</div>

<div class="search ctitle">
	<div class="tab">
		<span class="right"></span>
		<span class="font-blue14pxb">修改用户</span>
    </div>
</div>

<div class="tableBox fwidth">
	<form id="updateUserForm" name="updateUserForm" method="post" action="<%=path%>/servlet/UpdateServlet?key=doUpUser" >	
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<th class="h" width="30%">用户ID</th>
		<td class="text_left">
		<input id="userID" name="userID" type="text" value="${user.userID }"  readonly="readonly" style="width: 150px;color: #325f86;" />
		</td>
		
	  </tr>
	  <tr>
	     <th class="h">用户名</th>
	     <td class="text_left"><input name="userName" type="text" value="${user.userName }" style="width: 150px;color: #325f86;"/></td>
	  </tr>
	  <tr>
	     <th class="h">用户类型</th>
	     <td class="text_left">
	     	<c:choose>
	     		<c:when test="${'M'eq user.userType || 'm' eq user.userType}">
			     	监控管理员：<input name="userType" type="radio" value="M" checked="checked" style="color: #325f86;"/>
			     	普通用户：<input name="userType" type="radio" value="C" style="color: #325f86;"/>
	     		</c:when>
	     		<c:otherwise>
			     	监控管理员：<input name="userType" type="radio" value="M" style="color: #325f86;"/>
			     	普通用户：<input name="userType" type="radio" value="C" checked="checked" style="color: #325f86;"/>
	     		</c:otherwise>
	     	</c:choose>
	     </td>
	  </tr>
	  <tr>
	     <th class="h">所属公司</th>
	     <td class="text_left"><input name="company" type="text" value="${user.customerBean.company }" readonly="readonly" style="width: 150px;color: #325f86;"/></td>
	  </tr>
	  <tr>
	     <th class="h">所属角色</th>
	     <td class="text_left"><input type="hidden" name="resourceUserRole" id="resourceUserRole" value="${user.userRole.roleID}" />
	     <select name="userRole" id = "userRole" >
	     	<option value ="">请选择</option>
	     	<c:if test="${roleList != null}">
	     	<c:forEach var="role" items="${roleList}">
	     	<option value="${role.roleID}" ${user.userRole.roleID == role.roleID?"selected":""}>${role.name}</option>
	     	</c:forEach>
  			</c:if>
	     </select>
	     </td>
	  </tr>
	  <tr>
	     <th class="h">用户状态</th>
	     <td class="text_left">
	     <select id = "userDisable" name = "userDisable">
	     	<option value="1" ${user.userDisable=='1'?"selected":""} >正常</option>
	     	<option value="3" ${user.userDisable=='3'?"selected":""} >注销</option>
	     	<option value="5" ${user.userDisable=='5'?"selected":""} >锁定</option>
	     </select> 
	     </td>
	  </tr>
	
	  <tr>
		<th class="h">Email</th>
		<td class="text_left"><input name="emailAddress" type="text" value="${user.emailAddress}" style="width: 150px;color: #325f86;"/></td>
	  </tr>
	 
	  <tr>
		<th class="h">用户是否接受邮件通知</th>
        <td class="text_left"><input type ="hidden" name = "emailN" id ="emailN" value="${user.emailNotifications}" />
			 <input id="emailNotifications_c" name="emailNotifications" type="checkbox" value="${user.emailNotifications}" ${user.emailNotifications=='1'?"checked":""} onclick="updateEmailNotifications();"/>
	   		</td>
	  </tr>
	  <tr>
		<td colspan="2" align="center">
			<input type="submit" name="save" value="修 改" class="button" onMouseOver="this.className='button_mouseover'"
 onmouseout="this.className='button'"/>
		</td>
	  </tr>
	</table>
	</form>
   </div>	
</body>
</html>